/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ddbserver.common;

/**
 *
 * @author Roar
 */
public class ExceptionHandler {

    private static String[] errorType = {"Generic: ", "DDBServer: ", "SQL: "};
    private static String[][] errorMessage = {{
            "Ok!",
            "Unknow Error"
        }, {
            "Ok!",
            "Unknow Error"
        }, {
            "Ok!",
            "Unknow Error"
        }};

    public static String getMessage(int type, int code) {
        String error = "";
        if (type < errorType.length) {
            if (code < errorMessage[type].length) {
                error = errorType[type] + errorMessage[type][code];
            } else {
                error = errorType[type] + errorMessage[type][1];
            }
        } else {
            error = errorType[0] + errorMessage[0][1];
        }
        System.out.println(error);
        System.err.println(error);
        return error;
    }

    public static void handleExcptin(Exception e) {
        e.printStackTrace();
        e.printStackTrace(System.err);
    }
}
